#!/bin/bash

set -e

echo "Upgrading OMF commands"
sudo chmod 755 omf-5.4
sudo chown root:root omf-5.4
sudo mv omf-5.4 /usr/bin/

echo "Handling @ in username"
sudo chmod 644 saveimaged.rb
sudo chown root:root saveimaged.rb
sudo mv saveimaged.rb /usr/share/omf-aggmgr-5.4/omf-aggmgr/ogs_saveimage/
sudo chmod 644 gridService.rb
sudo chown root:root gridService.rb
sudo mv gridService.rb /usr/share/omf-aggmgr-5.4/omf-aggmgr/ogs/

echo "Upgrading definition of experiment ID and RC configuration file"
sudo chmod 644 experiment.rb
sudo chown root:root experiment.rb
sudo mv experiment.rb /usr/share/omf-expctl-5.4/omf-expctl/

echo "Upgrading database structure"
mysql -u root -p inventory < inventory.sql

echo "Script execution finished with success."
